function sn()

%
% generate a signal in noise figure


dt = 0.1;
an = 1;
as = .1;
clf;
mapdur = 5000;

[signal, dt] = tonepip(1, 0.25, 50, 80, 20, 0);
truedur = floor(length(signal)*dt);
if(truedur < mapdur) % milliseconds
    pad = floor(mapdur/dt)-length(signal);
    if(pad > 0)
        size(signal)
        size(zeros(pad, 1))
        signal = [signal; zeros(pad, 1)];
    end;
end;

noise = noisepip(1,2,150,10);
if(length(noise) > length(signal))
    noise = noise(1:length(signal));
end;
if(length(noise) < length(signal))
    signal = signal(1:length(noise));
end;
npts = length(signal);
fsamp = 1000/dt; % get sampling frequency
% original cutoff 1000 Hz.
fco = 500;		% cutoff frequency in Hz
wco = fco/(fsamp/2); % wco of 1 is for half of the sample rate, so set it like this...
if(wco < 1) % if wco is > 1 then this is not a filter!
    [b, a] = butter(8, wco); % butterworth
    noise = filter(b, a, noise); % filter all the traces...
end;

t = [0:dt:dt*(npts-1)];

sn = an*noise + as*signal;
t1 = t(1:10:length(t));
sn1 = sn(1:10:length(sn));
plot(t1, sn1);
hold on;
plot(t, as*signal, 'r-');
set(gca,'Ylim', [-0.4,0.3]);
%sound(sn1, 1/dt);